﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace wx_api.CSM.Dto
{
    internal class WxApiInput
    {
        [JsonProperty("method")]
        public string Method { get; set; }

        [JsonProperty("param")]
        public IDictionary<string, string> Params { get; set; }

        internal Guid GetID(string name)
        {
            if (Params.ContainsKey(name) && Guid.TryParse(Params[name], out var id)) return id;

            return Guid.Empty;
        }
        internal string GetText(string name)
        {
            if (Params.ContainsKey(name)) return Params[name];

            return string.Empty;
        }
        internal int GetNumber(string name)
        {
            if (Params.ContainsKey(name) && int.TryParse(Params[name], out int i)) return i;

            return 0;
        }
    }
}
